package item6;

public class SelectSort {

	public static void main(String[] args) {
		int[] array = new int[1000];
		for (int a = 0; a < array.length; a++) {
			array[a] = (int) (Math.random()*100);
		}
		SelectSort sorte = new SelectSort();
		long starttime = System.currentTimeMillis();
		array = sorte.sort(array);
		//sorte.showArray(array);
		System.out.println(System.currentTimeMillis()-starttime);
	}

	public int[] sort(int[] array) {
		int index;
		for (int i = 1; i < array.length; i++) {
			index = 0;
			for (int j = 1; j <= array.length - i; j++) {
				if (array[j] > array[index]) {
					index = j;
				}
			}
			int temp = array[array.length - i];
			array[array.length - i] = array[index];
			array[index] = temp;			
			//this.showArray(array);
		}
		return array;
	}

	public void showArray(int[] array) {
		for (int i : array) {
			System.out.print(">" + i);
		}
		System.out.println();
	}
}
